import { createStore } from 'vuex'
const store = createStore({
// 在这里定义您的state，mutations，actions等 })
    state: {
        totalNum:{}, // 在 state 中定义 totalNum
        foodList:[]
    },
    mutations: {
        setTotalNum(state, {key, value} ) {
             // 更新 totalNum 的值
            state.totalNum[key] = value;
            // console.log(state.totalNum[key])

        },
        setFoodList(state,foodList){
            state.foodList=foodList;
        }
    },
    actions: {
        // 其他 actions
    },
    getters: {
        // 定义一个 getter 来获取 totalNum 中指定键的值
        getTotalNum: (state) => (key) => {
            return state.totalNum[key];
        },
    }
})
export default store